# filtered_column_hcard_macro:
#   A macro for filtered_column rails plugin to generate
#   hcard microformat snippets
#
#
# == Synopsis
#
# <macro:hcard class="widget"
#               fn="Alca Societa' Cooperativa a.r.l."
#               nickname="ALCA"
#               email="info@alca.le.it"
#               photo="http://labs.alca.le.it/assets/2007/6/4/alcalabs.png">
# </macro:hcard>
#
# == Authors
#
# * Luca Greco <luca.greco@alca.le.it>
#
# == Copyright
#
#  Copyright (c) 2007 Alca Società Cooperativa
#   <http://alca.le.it/>
#   All rights reserved.
#
#
# filtered_column_hcard_macro is free software; you can redistribute it
# and/or modify it under # the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# filtered_column_hcard_macro is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#

class HCardMacro < FilteredColumn::Macros::Base

  def self.filter(attributes, inner_text = '', text = '')
    fn          = attributes[:fn] || ""
    nickname    = attributes[:nickname] || ""
    photo       = attributes[:photo] || "/images/avatar-nil.png"
    email       = attributes[:email] || ""
    css_class   = (attributes[:class] || "") + " vcard"

    hcard_block = <<-EOF
    <div class="#{css_class}">
      <img class="photo" src="#{photo}" />
      <dl>
        <dt>Full Name:</dt>
        <dd class="fn">#{fn}</dd>
        <dt>Nickname:</dt>
        <dd class="nickname">#{nickname}</dd>
        <dt>Email:</dt>
        <dd class="email">#{email}</dd>
        #{inner_text}
      </dl>
    </div>
    EOF
  end
end
